package com.bos.dao.imp;

import com.bos.dao.ISubareaDao;
import com.bos.dao.base.imp.BaseDaoImp;
import com.bos.domain.Subarea;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Administrator
 */
@Repository
public class ISubareaDaoImp extends BaseDaoImp<Subarea> implements ISubareaDao {

    @Override
    public List<Object> findSubareasByRegion() {
        /*使用map来封装数据，要用as 指定map中的key,不指定默认为构造器中的位置序号（从0开始）*/
        String hql = "select distinct new map (r.province as name,count (*) as y ) from Subarea s left join s.region r group by r.province";
        List<Object> objects = (List<Object>) this.getHibernateTemplate().find(hql);
        return objects;
    }
}
